/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mocks;


import server.*;
import engine.Singleton;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import sql.CreateTables;
import webClient.HttpClient;

/**
 *
 * @author Alexx
 */
public class MultiMockServer extends Thread
{
    static final int PORT = 8888;

    
    public static void main(String[] args) throws IOException, SQLException, Throwable
    {
        ServerSocket s = new ServerSocket(PORT);
        System.out.println("Server Started");
        Singleton.getInstance();
        CreateTables.creator();
     //   HttpClient.fire();
        try
        {
            while (true)
            {
         //     HttpClient.fire();
                Socket socket = s.accept();
                try
                {
                    OneThreadMock clients = new OneThreadMock(socket);
                    System.out.println("");
                    
                }
                catch (IOException e)
                {
                    socket.close();
                }
            }
        }
        finally
        {
            s.close();
        }
    }
    
    public void run()
    {
        try
        {
      ServerSocket s = new ServerSocket(PORT);
        System.out.println("Server Started");
        Singleton.getInstance();
      try {
        CreateTables.creator();
      } catch (SQLException ex) {
        Logger.getLogger(MultiMockServer.class.getName()).log(Level.SEVERE, null, ex);
      }
     //   HttpClient.fire();
        try
        {
            while (true)
            {
         //     HttpClient.fire();
                Socket socket = s.accept();
                try
                {
                    ServeOneThread clients = new ServeOneThread(socket);
                     
                }
                catch (IOException e)
                {
                    socket.close();
                }
            }
        }
        finally
        {
            s.close();
        }
    }
    catch (IOException ex) {
      Logger.getLogger(MultiMockServer.class.getName()).log(Level.SEVERE, null, ex);
    
    }
    
  }
}
